package demo.service;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import demo.dao.IShopcartDao;
import demo.model.Shopcart;

@Service
public class ShopcartServicelmpl implements IShopcartService {

	
	@Resource
	private IShopcartDao dao;
	
	
	@Override
	public int addCart(Shopcart cart) {
		//判断要添加的商品是不是已经在顾客的购物车中了
		int n = dao.findCart(cart);
		if(n>0){//如果有改变数量
			n =	dao.editCart(cart);
		}else{//如果没有
			n =	dao.addCart(cart);
		}
		return 0;
	}

}
